package com.greedy.controller;


import com.greedy.service.VoucherOrderService;
import com.greedy.utils.Result;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: Yanxy
 * @Date: Created in:2022-12-24
 * Description: 优惠卷下单
 */
@RestController
@RequestMapping("/voucher-order")
public class VoucherOrderController {

    @Resource
    private VoucherOrderService voucherOrderService;

    /**
     * 秒杀优惠券
     * @param voucherId 优惠券ID
     * @return 用户拥有购买资格，返回订单ID。否侧返回其它标识：库存不足/该用户已经下过单
     */
    @PostMapping("/seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId) {
        return voucherOrderService.seckillVoucher(voucherId);
    }
}
